home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Jeopardy;
-
- {This program has been post-documented to the best of my abilities...
- considering I started three other projects after this, I'm not sure
- of everything; You programmers out there will probably understand
- most of it anyhow! - June 15, 1987 by Vinny Salzillo}
-
- LABEL 100;
-
- CONST
- {$I GEMCONST.PAS}
-
- TYPE
- {$I GEMTYPE.PAS}
- Boardtype = ARRAY [1..6,1..6] OF Boolean; {Answer revealed yet?}
- Anstype = ARRAY [1..6,1..6] OF String[224]; {Answer strings,formatted}
- Ansfile = FILE OF String[224]; {by the Answer program}
-
- VAR
- Main_Screen:Window_Title;
- xpos,ypos,x1,y1,game,Choice,Main:Integer;
- Board:Boardtype;
- first,good,xit,sd,fj:Boolean;
- Answers:Anstype;
- Ansvar:Ansfile;
- def_path,filename:Path_Name;
-
- {$I GEMSUBS.PAS}
-
- PROCEDURE Text_Height (height:integer); {Obvious}
-
- TYPE
- Ctrl_Parms = ARRAY [0..11] OF integer;
- Int_In_Parms = ARRAY [0..15] OF integer;
- Int_Out_Parms = ARRAY [0..45] OF integer;
- Pts_In_Parms = ARRAY [0..11] OF integer;
- Pts_Out_Parms = ARRAY [0..11] OF integer;
-
- VAR
- control:Ctrl_Parms;
- int_in:Int_In_Parms;
- int_out:Int_Out_Parms;
- pts_in:Pts_In_Parms;
- pts_out:Pts_Out_Parms;
-
- PROCEDURE VDI_Call(cmd,sub_cmd,nints,npts:Integer;
- VAR ctrl:Ctrl_Parms;
- VAR int_in:Int_In_Parms;VAR int_out:Int_Out_Parms;
- VAR pts_in:Pts_In_Parms;VAR pts_out:Pts_Out_Parms;
- translate:Boolean);
- EXTERNAL;
-
- BEGIN
- pts_in[0]:=0;
- pts_in[1]:=height;
- VDI_Call(12,0,0,2,control,int_in,int_out,pts_in,pts_out,false);
- END;
-
- PROCEDURE Init_Board;
-
- VAR
- x,y:Integer;
-
- BEGIN
- FOR x:=1 TO 6 DO
- BEGIN
- Board[x,1]:=False;
- FOR y:=2 TO 6 DO
- Board[x,y]:=True; {The answer squares are formatted to true,}
- END; {which means UNUSED}
- END;
-
- PROCEDURE Set_Screen;
-
- BEGIN
- IF Init_Gem>=0 THEN
- BEGIN
- xit:=False;
- Main:=New_Window(0,Main_Screen,0,0,0,0); {Only window needed, full scr}
- Open_Window(Main,0,0,0,0)
- END;
- END;
-
- PROCEDURE Draw_Board;
-
- VAR
- a,b,x,y:Integer;
-
- BEGIN
- Hide_Mouse;
- Clear_Screen;
- Draw_Mode(1); {Also obvious}
- Line(0,0,0,397);
- Line(2,0,2,397);
- Line(638,0,638,397);
- Line(2,397,638,397);
- Line(0,399,639,399);
- Line(2,79,638,79);
- Line(2,80,638,80);
- Line(2,81,638,81);
- Line(2,82,638,82);
- Line(2,144,638,144);
- Line(2,146,638,146);
- Line(2,207,638,207);
- Line(2,209,638,209);
- Line(2,270,638,270);
- Line(2,272,638,272);
- Line(2,333,638,333);
- Line(2,335,638,335);
- Line(107,0,107,397);
- Line(109,0,109,397);
- Line(213,0,213,397);
- Line(215,0,215,397);
- Line(319,0,319,397);
- Line(321,0,321,397);
- Line(425,0,425,397);
- Line(427,0,427,397);
- Line(531,0,531,397);
- Line(533,0,533,397);
- Draw_Mode(3);
- FOR a:=0 TO 4 DO
- BEGIN {Rounding corners}
- FOR b:=0 TO 3 DO
- BEGIN
- x:=((a+1)*108)-(2*a);
- y:=(145+63*b);
- PLOT(x-1,y);
- PLOT(x+1,y);
- PLOT(x,y-1);
- PLOT(x,y+1)
- END;
- END;
- Draw_Mode(1);
- Show_Mouse;
- END;
-
- PROCEDURE Draw_Money (sd:Boolean);
-
- VAR
- mon,x,y:Integer;
-
- PROCEDURE Do_Money(i,j:Integer;sd:Boolean);
-
- VAR
- ds,Indent:Integer; {Put the dollar amounts on the board,}
- money:String[7]; {provided that the particular square}
- a:String[2]; {reads false (unused)}
-
- BEGIN
- IF sd THEN
- ds:=2
- ELSE
- ds:=1;
- mon:=j*ds;
- IF mon=10 THEN
- BEGIN
- money:='$1000'; {I couldn't figure out any other way to do}
- Indent:=17 {the $1000, any suggestions?}
- END;
- IF mon<10 THEN
- BEGIN
- mon:=mon+48;
- money:=Concat('$',chr(mon),'00');
- Indent:=25
- END;
- Draw_String((Indent+((i-1)*106)),(123+((j-1)*63)),money)
- END;
-
- BEGIN
- Text_Height(24);
- Text_Style(Normal);
- Hide_Mouse;
- FOR x:=1 TO 6 DO
- BEGIN
- FOR y:=2 TO 6 DO
- BEGIN
- IF Board[x,y] THEN
- Do_Money(x,y-1,sd)
- END;
- END;
- Show_Mouse
- END;
-
- PROCEDURE Draw_Titles;
-
- VAR
- x,y:Integer;
- a:Boolean;
- part:String[20];
-
- BEGIN
- Text_Height(7);
- Text_Style(Normal);
- Hide_Mouse;
- FOR x:=1 TO 6 DO
- BEGIN {Put the titles at the top of the}
- a:=False; {board, provided the category still}
- FOR y:=2 TO 6 DO {has answers left}
- IF Board[x,y] THEN
- a:=True;
- IF a THEN
- BEGIN
- part:=Copy(Answers[x,1],1,11);
- Draw_String(4+(106*(x-1)),20,part);
- part:=Copy(Answers[x,1],12,11); {String manipulation which}
- Draw_String(4+(106*(x-1)),38,part); {will make lots more sense}
- part:=Copy(Answers[x,1],23,11); {when I release the}
- Draw_String(4+(106*(x-1)),56,part); {answer generator}
- part:=Copy(Answers[x,1],34,11);
- Draw_String(4+(106*(x-1)),74,part)
- END;
- END;
- Show_Mouse;
- END;
-
- PROCEDURE Event_Loop;
-
- VAR
- event,dummy:Integer;
- msg:Message_Buffer;
-
- BEGIN
- event:=0;
- WHILE event<>E_Button DO
- event:=Get_Event(E_Button,
- 1,1,1,0,
- False,0,0,0,0,False,0,0,0,0,
- msg,dummy,
- dummy,dummy,
- xpos,ypos,
- dummy);
- event:=0; {Wait for a left click only}
- WHILE event<>E_Button DO
- event:=Get_Event(E_Button,
- 1,0,1,0,
- False,0,0,0,0,False,0,0,0,0,
- msg,dummy,
- dummy,dummy,
- dummy,dummy,
- dummy)
- END;
-
- PROCEDURE Interpret;
-
- VAR
- b1:Integer;
-
-
- PROCEDURE do_goodx(b1:Integer);
-
- BEGIN
- good:=true;
- x1:=b1
- END;
-
- PROCEDURE do_goody(b1:Integer);
-
- BEGIN
- good:=true;
- y1:=b1
- END;
-
- BEGIN
- x1:=1;
- y1:=1;
- IF (xpos>2) AND (xpos<107) THEN
- do_goodx(1);
- IF (xpos>109) AND (xpos<213) THEN
- do_goodx(2); {This routine finds the square}
- IF (xpos>215) AND (xpos<319) THEN {that the user clicked on...}
- do_goodx(3);
- IF (xpos>321) AND (xpos<425) THEN
- do_goodx(4);
- IF (xpos>427) AND (xpos<531) THEN
- do_goodx(5);
- IF (xpos>533) AND (xpos<638) THEN
- do_goodx(6);
- IF (ypos>82) AND (ypos<144) THEN {The routine which follows}
- do_goody(2); {one will determine whether}
- IF (ypos>146) AND (ypos<207) THEN {it was a legitimate choice!}
- do_goody(3);
- IF (ypos>209) AND (ypos<270) THEN
- do_goody(4);
- IF (ypos>272) AND (ypos<333) THEN
- do_goody(5);
- IF (ypos>335) AND (ypos<397) THEN
- do_goody(6);
- IF Board[x1,y1]=False THEN
- good:=False
- END;
-
- PROCEDURE Daily_Double;
-
- BEGIN
- Hide_Mouse;
- Clear_Screen;
- Draw_Mode(1);
- Text_Style(Thickened|Shadowed);
- Text_Height(50);
- Paint_Style(17);
- Paint_Oval(320,200,250,150); {Simple enough}
- Paint_Style(1);
- Draw_Mode(2);
- Draw_String(279,180,'DAILY');
- Draw_String(271,250,'DOUBLE');
- Delete(Answers[x1,y1],1,1); {<-- This routine eliminates the}
- Insert(' ',Answers[x1,y1],1); {backslash, which is the signal}
- Draw_Mode(1); {for a Daily Double}
- Text_Style(Normal);
- Show_Mouse;
- Event_Loop
- END;
-
- PROCEDURE Show_Answer;
-
- VAR
- a1:Integer;
- part:String[30];
- dd_test:String[5];
-
- BEGIN
- dd_test:=Copy(Answers[x1,y1],1,1);
- IF dd_test='\' THEN Daily_Double; {See above}
- Hide_Mouse;
- Clear_Screen;
- Draw_Mode(1);
- Text_Height(50);
- FOR a1:=1 TO 8 DO
- BEGIN
- part:=Copy(Answers[x1,y1],1+((a1-1)*28),28); {Text is already}
- Draw_String(97,(33+(a1*40)),part) {formatted by the}
- END; {answer generator}
- Board[x1,y1]:=False; {so all that's left is to show}
- Show_Mouse; {all eight lines and set the}
- Event_Loop {square to USED}
- END;
-
- PROCEDURE Load_file;
-
- VAR
- fil:Boolean;
- x,y:Integer;
-
- BEGIN
- def_path:='a:\*.JPD';
- fil:=Get_In_File(def_path,filename);
- If NOT fil THEN
- GOTO 100;
- Reset (ansvar,filename);
- FOR x:=1 TO 6 DO
- FOR y:=1 TO 6 DO
- BEGIN
- Get(ansvar);
- Answers[x,y]:=ansvar^
- END;
- Close(ansvar);
- Hide_Mouse;
- Clear_Screen;
- Show_Mouse
- END;
-
- PROCEDURE Normal_Jeopardy;
-
- VAR
- count:Integer;
-
- BEGIN
- count:=1;
- first:=True;
- WHILE count<31 DO
- BEGIN
- Draw_Board;
- Draw_Money(sd);
- If first THEN Event_Loop;
- first:=False;
- Draw_Titles;
- good:=False;
- WHILE NOT good DO
- BEGIN
- Event_Loop;
- Interpret
- END;
- Show_Answer;
- count:=count+1
- END;
- END;
-
- PROCEDURE Final_Jeopardy;
-
- VAR
- part:String[20];
-
- BEGIN
- Hide_Mouse;
- Clear_Screen;
- Text_Style(Thickened|Shadowed);
- Text_Height(50);
- Paint_Style(14);
- Paint_Oval(320,200,250,150);
- Paint_Style(1);
- Draw_Mode(2);
- Draw_String(279,180,'FINAL');
- Draw_String(253,250,'JEOPARDY');
- Show_Mouse;
- Event_Loop;
- Hide_Mouse;
- Draw_Mode(1);
- Text_Style(Normal);
- Text_Height(16);
- part:=Copy(Answers[1,1],1,11);
- Draw_String(10,25,part);
- part:=Copy(Answers[1,1],12,11);
- Draw_String(10,50,part);
- part:=Copy(Answers[1,1],23,11);
- Draw_String(10,75,part);
- part:=Copy(Answers[1,1],34,11);
- Draw_String(10,100,part);
- x1:=1;
- y1:=2;
- Show_Mouse;
- Event_Loop;
- Show_Answer
- END;
-
- PROCEDURE Start_Game;
-
- VAR
- title:String[255];
-
- BEGIN
- Load_File;
- title:=Concat('[2][ JEOPARDY! |',
- ' Revision 1.0 |',
- '(C) 1987 VDS Inc.|',
- ' |',
- 'Type of game? ]',
- '[Single|Double|Final]');
- game:=Do_Alert(title,0);
- fj:=False;
- CASE game OF
- 1:sd:=False;
- 2:sd:=True;
- 3:fj:=True
- END;
- Set_Mouse(M_Point_Hand);
- IF fj THEN
- Final_Jeopardy
- ELSE
- Normal_Jeopardy;
- Set_Mouse(M_Arrow)
- END;
-
- BEGIN
- Set_Screen;
- LOOP
- Init_Board;
- Start_Game;
- Choice:=Do_Alert('[2][ What Next? ][Restart|Exit]',1);
- IF Choice=2 THEN
- xit:=True;
- EXIT IF xit
- END;
- Exit_Gem;
- 100: END.
-
- {The rest of this file is really self-explanatory...but if you have
- questions, I'll do my best to help you. All I ask is that if you come
- up with an improvement, let me know, and I will give you credit for it!
- Contact: Vinny Salzillo (V.Salzillo on GEnie) 212-881-4575
- 2535 Matthews Ave. Bronx, NY 10467...Have fun with this program, and
- let me know what you think!}
-
-
-